package com.meet.controller;

import com.meet.bizservice.SocialService;
import com.meet.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Min;

@RestController
@RequestMapping("/friends")
@CrossOrigin
@Validated
public class MeetSocialController {

    @Autowired
    private SocialService socialService;

    @GetMapping("/list")
    public Result<?> getFriendsList(@RequestParam(defaultValue = "1") @Min(1) int page,
                                    @RequestParam(defaultValue = "10") @Min(1) int limit) {
        return socialService.getFriendsList(page, limit);
    }

    @PostMapping("/add")
    public Result<?> addFriend(@RequestBody @Validated FriendAddRequest request) {
        return socialService.addFriend(request.getFriendId());
    }

    // Request DTO
    public static class FriendAddRequest {
        @NotBlank(message = "好友ID不能为空")
        private String friendId;

        // Getters and Setters
        public String getFriendId() {
            return friendId;
        }

        public void setFriendId(String friendId) {
            this.friendId = friendId;
        }
    }
}
